<!DOCTYPE html>
<html>
<head>
<!--{if $isGbk}-->
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<!--{else}-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{/if}-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0 , maximum-scale=1.0, user-scalable=0">
<title>{$jyConfig['plugin_name']}</title>
<meta name="description" content=""/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link href="source/plugin/tom_love/images/style.css?v={$cssJsVersion}" rel="stylesheet" type="text/css">
<script src="source/plugin/tom_love/images/jquery.js"></script>
<script type="text/javascript">
    var commonjspath = 'source/plugin/tom_love/images';
</script>
<script src="source/plugin/tom_love/images/common.js?v={$cssJsVersion}" type="text/javascript"></script>
<base target="_self">
</head>
<body>
<header class="header_style2 clearfix">
	<a href="plugin.php?id=tom_love&mod=my"></a>
	<h1>{lang tom_love:vip_pay_title}</h1>
</header>
<header class="score_box clearfix">
	<div class="score_top_box clearfix">
    	<figure><img src="source/plugin/tom_love/images/vip_ico.png"></figure>
        <article>
        	<header>{lang tom_love:vip_pay_grade}:</header>
            <footer><!--{if $__UserInfo['vip_id'] == 1}-->{lang tom_love:vip_pay_grade_gold}<!--{else}-->{lang tom_love:vip_pay_grade_normal}<!--{/if}--></footer>
        </article>
    </div>
    <div class="box_both clearfix"></div>

    <div class="score_recharge_box from_class clearfix">
        <div class="score_recharge_msg clearfix" style="height: 25px;">
        <p>{lang tom_love:vip_pay_overtime}{lang tom_love:score_fg}<span><!--{if $__UserInfo['vip_id'] > 0}-->{$vipTime}<!--{else}--> - - <!--{/if}--></span></p>
    </div>
    <form id="payForm">
        <table>
          <colgroup><col width="25%"><col><col width="75%"><col></colgroup>
          <tbody>
          <tr>
              <td>{lang tom_love:vip_pay_grade}:</td>
              <td>
                    <select name="vip_id">
                        <option value="1">{lang tom_love:vip_pay_grade_gold}</option>
                    </select>
              </td>
          </tr>
          <tr>
              <td>{lang tom_love:vip_pay_paytime}:</td>
              <td>
                    <select name="month_id">
                        <!--{loop $yuan_vip1Arr $key $val}-->
                        <option value="{$key}">{$key}{lang tom_love:vip_pay_month_id1}{$val}{lang tom_love:vip_pay_month_id2}</option>
                        <!--{/loop}-->
                    </select>
                  <input type="hidden" name="openid" value="{$openid}">
                  <input type="hidden" name="act" value="vip">
                  <input type="hidden" name="user_id" value="{$__UserInfo['id']}">
                  <input type="hidden" name="formhash" value="{$formhash}">
              </td>
          </tr>
          </tbody>
      </table>
      </form>
    </div>
    <div class="score_recharge_btn clearfix">
    	<a href="javascript:void(0);" class="id_pay_btn">{lang tom_love:vip_pay_title}</a>
    </div>
    <div class="box_both clearfix"></div>
    <div class="score_more_box clearfix">{$vip_payString}</div>
</header>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script>
var submintPayStatus = 0;
var jsApiParameters;

function jsApiCall(){
    WeixinJSBridge.invoke(
        'getBrandWCPayRequest',{
            "appId": jsApiParameters.appId,
            "timeStamp": jsApiParameters.timeStamp,
            "nonceStr": jsApiParameters.nonceStr,
            "package": jsApiParameters.package,
            "signType": jsApiParameters.signType,
            "paySign": jsApiParameters.paySign
        },
        function(res){
            if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                loading(false);
                submintPayStatus = 0;
                tusi("{lang tom_love:scorepay_pay_succ}");
                setTimeout(function(){document.location.reload();},1888);
            }else{
                loading(false);
                submintPayStatus = 0;
                tusi("{lang tom_love:scorepay_pay_error}");
                setTimeout(function(){document.location.reload();},1888);
            } 
        }
    );
}

function callpay(){
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
            document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
        }
    }else{
        jsApiCall();
    }
}
$(document).ready(function(){
  $.get("{$ajaxClicksUrl}");
});
$(".id_pay_btn").click( function () { 
    if(submintPayStatus == 1){
        return false;
    }
    loading('{lang tom_love:scorepay_do}');
    submintPayStatus = 1;
    $.ajax({
        type: "GET",
        url: "{$payUrl}",
        dataType : "json",
        data: $('#payForm').serialize(),
        success: function(data){
            if(data.status == 200) {
                jsApiParameters = data.parameters;
                setTimeout(function(){callpay();},500);
            }else if(data.status == 301){
                loading(false);
                tusi("{lang tom_love:scorepay_order_error301}");
                setTimeout(function(){document.location.reload();},1888);
            }else if(data.status == 302){
                loading(false);
                tusi("{lang tom_love:scorepay_order_error302}");
                setTimeout(function(){document.location.reload();},1888);
            }else if(data.status == 303){
                loading(false);
                tusi("{lang tom_love:scorepay_order_error303}");
                setTimeout(function(){document.location.reload();},1888);
            }else if(data.status == 304){
                loading(false);
                tusi("{lang tom_love:scorepay_order_error304}");
                setTimeout(function(){document.location.reload();},1888);
            }else{
                loading(false);
                tusi("{lang tom_love:scorepay_order_error}");
                setTimeout(function(){document.location.reload();},1888);
            }
        }
    });
});

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    WeixinJSBridge.call('hideToolbar');
});
wx.config({
    debug: false,
    appId: '{$wxJssdkConfig["appId"]}',
    timestamp: {$wxJssdkConfig["timestamp"]},
    nonceStr: '{$wxJssdkConfig["nonceStr"]}',
    signature: '{$wxJssdkConfig["signature"]}',
    jsApiList: [
      'onMenuShareTimeline',
      'onMenuShareAppMessage'
    ]
});
wx.ready(function () {
    wx.onMenuShareTimeline({
        title: '{$shareTitle}',
        link: '{$shareUrl}', 
        imgUrl: '{$shareLogo}', 
        success: function () { 
            $.get("{$shareAjaxUrl}");
        },
        cancel: function () { 
        }
    });
    wx.onMenuShareAppMessage({
        title: '{$shareTitle}',
        desc: '{$shareDesc}',
        link: '{$shareUrl}',
        imgUrl: '{$shareLogo}',
        type: 'link',
        dataUrl: '',
        success: function () { 
            $.get("{$shareAjaxUrl}");
        },
        cancel: function () { 
        }
    });
});
</script>
</body>
</html>